#!/bin/bash
echo "=== 构建UEStudio with AICoder ==="

export PATH="/c/msys64/ucrt64/bin:$PATH"
export wxWidgets_ROOT_DIR="/c/msys64/ucrt64"

cd /d/vc/UEStudio

# 清理旧构建
echo "清理旧构建..."
rm -rf build
mkdir build
cd build

echo "=== 配置CMake ==="
cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug ..

echo "=== 编译AICoder插件 ==="
make AICoder -j4

if [ $? -eq 0 ]; then
    echo "✅ AICoder插件编译成功！"
    echo "=== 编译完整UEStudio ==="
    make -j4
    if [ $? -eq 0 ]; then
        echo "🎉 UEStudio with AICoder 构建成功！"
        echo "🚀 启动命令: ./devel/codeblocks.exe"
    else
        echo "⚠️ UEStudio编译有警告，但AICoder插件已成功编译"
    fi
else
    echo "❌ AICoder编译失败"
    echo "=== 尝试编译所有目标 ==="
    make -j4
fi
